<?php 

/**
 * Joomla! 1.5 component arts_curriculum
 * @package    arts_curriculum
 * @subpackage
 * @author     Chris Borkowski {@link http://www.guggenheim.org}
 * @author     Created on 31-August-2009
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.view');
/**
  * HTML View class for the arts_curriculum component
  * @package Arts_curriculum
  */
  class Arts_curriculumViewCategories extends JView
  {
	function display( $tpl = null)
	{
		global $mainframe, $option;
	 
	 	$document =& JFactory::getDocument();
		$document->addStyleSheet($this->baseurl.'/components/com_arts_curriculum/css/ac_front.css');
		//$document->addScript( '/components/com_arts_curriculum/js/jquery.infinitecarousel.js' );
		//$document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js');
		//$document->addScriptDeclaration("$(function(){
		//$('#carousel').infiniteCarousel({
		//displayTime: 6000,
		//textholderHeight : .25
		//	});
		//});
		//");
		
		// Get the page/component configuration
	  	$params = &$mainframe->getParams();
	 	$menus = &JSite::getMenu();
	  	$menu = $menus->getActive();
		
		//we are overiding the global template "guggenheim" for this view ONLY and setting it to the one we prefer.
		$mainframe->setTemplate = "guggenheim_collections";
		
	 	$categories =& $this->get('data');
	 	$total =& $this->get('total');
	  	$state =& $this->get('state');
		$images =& $this->get('images');
		$intro =& $this->get('intro');
	 
	 	//load & process system content plugins ! note we are running it on the intro array to crank in the loadpostion module
		$dispatcher = & JDispatcher::getInstance();
		JPluginHelper::importPlugin('content');
		$results = $dispatcher->trigger('onPrepareContent', array (& $intro, & $params, 0));
		//$intro->main_body = JHTML::_('content.prepare', $intro[0]->main_body);
	  	
	 	// because the application sets a default page title, we need to get it
	  	// right from the menu item itself
	  	if (is_object( $menu )) {
	  	$menu_params = new JParameter( $menu->params );
	  	if (!$menu_params->get( 'page_title')) {
	  	$params->set('page_title', JText::_( 'ARTS_CURRICULUM' ));
	  	}
	  	} else {
	  	$params->set('page_title', JText::_( 'ARTS_CURRICULUM' ));
	  	}
	 	$document->setTitle( $params->get( 'page_title' ) );
	 
	 	// Set some defaults if not set for params
	 	$params->def('comp_description', JText::_('ARTS_CURRICULUM_DESC'));
	 
	 	//feed view
	 	// Add alternate feed link
		if($params->get('show_feed_link', 1) == 1)
		{
		
		$link = 'index.php?option='.$option.'&format=feed&limitstart=';
		$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
		$document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
		$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
		$document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
		}
	 	
	 	
	 	
	 	// Define image tag attributes
	  	if ($params->get('image') != -1)
	  	{
	  	if($params->get('image_align')!="")
	  	$attribs['align'] = $params->get('image_align');
	  	else
	  	$attribs['align'] = '';
	  	$attribs['hspace'] = 6;
	  	
	  	// Use the static HTML library to build the image tag
	  	$image = JHTML::_('image', 'images/stories/'.$params->get('image'), JText::_('ARTS_CURRICULUM'), $attribs);
	  	}
	 	for($i = 0; $i < count($categories); $i++)
	  	{
	  	$category =& $categories[$i];
	  	$category->link = JRoute::_('index.php?option=com_arts_curriculum&view=category&id='. $category->slug);
	 
	 	// Prepare category description
	  	$category->description = JHTML::_('content.prepare', $category->description);
		}
	 
	 	$this->assignRef('images', $images);
	 	$this->assignRef('intro', $intro);
	 	$this->assignRef('image', $image);
	  	$this->assignRef('params', $params);
	  	$this->assignRef('categories', $categories);
	 
	 	parent::display($tpl);
  		
  		}
  }
?>
